package com.msb.serviceorder.controller;


import com.msb.commons.constant.HeaderParmaConstants;
import com.msb.commons.dto.OrderDTO;
import com.msb.commons.response.ResponseResult;
import com.msb.serviceorder.service.OrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chshh
 * @since 2022-11-06
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderInfoController {
    @Autowired
    private OrderInfoService orderInfoService;

    @PostMapping("/add")
    public ResponseResult add(@RequestBody OrderDTO orderDTO, HttpServletRequest httpServletRequest){
        //获取设备唯一码
        String deviceCode = httpServletRequest.getHeader(HeaderParmaConstants.DEVICE_CODE);
        orderDTO.setDeviceCode(deviceCode);

        return orderInfoService.add(orderDTO);
    }
}

